<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>滴答办公系统-学员导入</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		  content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="/media/layui/css/layui.css" media="all">
	<link type="text/css" rel="stylesheet" href="/media/toastr/toastr.min.css">
	<script src="/media/js/jquery.min.js"></script>
	<script type="text/javascript" src="/media/toastr/toastr.min.js"></script>
</head>
<body>
<div class="layui-container" style="margin-top: 5px">
	<form class="layui-form" action="studentbatch.do" method="post" enctype="multipart/form-data">
		<div class="layui-form-item">
			<label class="layui-form-label">下载模板</label>
			<div class="layui-input-block">
				<div class="layui-form-mid layui-word-aux">
					<a href="/media/tem/StudentsExcel.xls">批量导入学员模板.xls</a>
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">所属班级</label>
			<div class="layui-input-block">
				<select name="classId" id="cds">
				</select>
			</div>
		</div>


		<div class="layui-form-item">
			<label class="layui-form-label">选择文件</label>
			<div class="layui-input-block">
				<input type="file" name="mFile" id="no1" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<input class="layui-btn" style="margin-left: 10%"  id="btn1" type="submit" value="确认导入">
		</div>
	</form>
</div>
<script src="/media/layui/layui.js"></script>
<script>

	var form;
	layui
			.use(
					[ 'form','upload', 'layedit', 'laydate' ],
					function() {
						form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
						var upload = layui.upload;

						//执行实例
						var uploadInst = upload.render({
							elem: '#upfile' //绑定元素
							,url: '/photoupload' //上传接口
							,done: function(obj){
								//上传完毕回调
								console.log(obj);
								if(obj.code==200){
									$("#p1").val(obj.message);
									$("#img1")[0].src="/media/images/"+obj.message;
									$("#btn1").attr("disabled",false);
								}else{
									$("#img1")[0].src="media/images/cw1.jpg";
								}

							}
							,error: function(){
								//请求异常回调
							}
						});
						//日期
						laydate.render({
							elem : '#date'
						});


						//自定义验证规则
						form.verify({
							title : function(value) {
								if (value.length < 5) {
									return '标题至少得5个字符啊';
								}
							},
							pass : [ /(.+){6,12}$/, '密码必须6到12位' ],
							content : function(value) {
								layedit.sync(editIndex);
							}
						});
						initData();
					});


	function initData() {
		$.ajax({
			url: "/getClassName",
			success: function (data) {
				var a = JSON.parse(data)
				for (var i = 0; i < a.length; i++) {
					var c = a[i];
					$("#cds").append("<option value=\"" + c.id + "\">" + c.className + "</option>")
				}
				form.render("select");
			}
		})
	}
</script>
</body>
</html>